﻿package {
	import idv.cjcat.pyronova.nodes.FillRect;
	import idv.cjcat.pyronova.nodes.Node;
	import idv.cjcat.pyronova.nodes.SpriteSheet;
	
	public class Main extends PyronovaExample {
		
		[Embed(source = "mario.png")]
		private var MarioSpriteSheet:Class;
		
		private var spriteSheet:SpriteSheet;
		
		public function Main():void {
			super("SpriteSheet");
		}
		
		override protected function buildPreprocessor():Node {
			//clean buffer
			return new FillRect(view.bitmapData().rect, 0x00000000);
		}
		
		override protected function buildRoot():Node {
			spriteSheet = new SpriteSheet(new MarioSpriteSheet().bitmapData, 16, 32);
			spriteSheet.center.set(8, 16);
			spriteSheet.position.set(160, 100);
			
			return spriteSheet;
		}
		
		private var _temp:Number = 0;
		override protected function mainLoop():void {
			_temp += 0.2;
			spriteSheet.index = int(_temp);
		}
	}
}